import time
import os

def moveFile(fname, tagetDir):
    cmd = "mv" + " " + fname + " " + "./" + tagetDir + "/" + fname
    os.system(cmd)

def main():
    if not os.path.exists(dirName):
        os.system("mkdir " + dirName)
    text = "this is log file"
    fileName = "log1.txt"
    fileHandle = open(fileName, "w")
    fileHandle.write(text)
    fileHandle.close()
    moveFile(fileName, dirName)

dirName = "dir"
fileName = "log1.txt"

if __name__ == '__main__':
    main()


